<?php

namespace App\Http\Controllers\Home;

use App\Models\Card;
use App\Models\Member;

class CardController extends BaseController
{

    public function __construct(Member $member,Card $card , \App\Models\User $user)
    {
        parent::__construct();
        $this->member = $member;
        $this->card = $card;
        $this->user = $user;
    }

    /**
     *  获得卡内余额
     */
    public function getCardRes(){

          $res = $this->card->getCardRes(request());
          return ajax_return($res);
    }

    /**
     * 获取我的就诊卡列表
     */
    public function getMyList(){
         $res = $this->card->getMyCard(request());
         return ajax_return($res);
    }



    /**
     * @return 绑卡界面
     */
    public function getBindCardInfo(){
        $res = $this->member->getMemberById(request());
        $user = $this->user->getUserById(array('id'=>request('mid')));
        $data['member'] = $res;
        $data['user'] = $user;
        return ajax_return($data);
    }

    public function postLossCard(){
         $res = $this->card->losscard(request());
         return ajax_return($res);
    }

    /**
     * 绑卡
     * @return
     */
    public function postAddBindCard(){
        $res = $this->card->bindCard(request());
        return ajax_return($res);
    }

    /**
     * 绑卡删除
     */
    public function postDelBindCard(){
        $res = $this->card->delCard(request());
        return ajax_return($res);
    }
}
